package com.twp.auth.client;

import com.twp.common.basic.IBaseRequest;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * Created by tanweiping on 17/8/1.
 */
@FeignClient(name = "loginServiceClient",url = "http://127.0.0.1:8991/")
public interface LoginServiceClient extends IBaseRequest {

    @PostMapping("/oauth/token")
    ResponseEntity<OAuth2AccessToken> login(
            @RequestHeader("Content-Type") String contentType,
            @RequestHeader("Authorization") String authorization,
            @RequestParam Map<String, String> parameters);

    @PostMapping("/oauth/token")
    ResponseEntity<OAuth2AccessToken> refresh(
            @RequestHeader("Content-Type") String contentType,
            @RequestHeader("Authorization") String authorization,
            @RequestParam Map<String, String> parameters
    );
}
